/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Class.SaveArr;
import UIClass.ImgPrinter;
import UIClass.SendMail;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.PixelGrabber;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
import UIClass.imageHelper;
import java.awt.color.ColorSpace;
import java.awt.image.ColorConvertOp;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RenderedImage;
import java.awt.image.RescaleOp;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.GrayFilter;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author thu
 */
public class ViewPhotos extends javax.swing.JDialog {

    /**
     * Creates new form FullScreen
     */
    private static ArrayList<File> lstImg;
    private static int indexImage;
    private JPopupMenu Pmenu;
    private ArrayList<JLabel> arrThumnail;
    private JMenuItem menuItem;
    private static int xwidth;
    private static int yheight;
    private ImageIcon Original;
    private static int w;//imgmain
    private static int h;
    private static double zoom;
    private static int flag_cut;//cờ cắt ảnh
    int iSecond = 3;
    private static int imgthumn;//vị trí đang chọn của thumnail
    java.awt.Frame frmparent;
    private int indexBlur = 3;
    private ImageIcon imgRoot;
     private ImageIcon imgUndo;
    private int left;// chỉnh quay trái phải
    private int right;
    private Image imgRo;
     private Image imgRo2;
     private Image imgRo3;
    private int leftRo;
    private int rightRo;
    private Image imgRo1;
    private Image imgsave;//luw lại image 
    private ImageIcon CtrlZ;
    private ArrayList<SaveArr> savearr;
   

    public ViewPhotos(java.awt.Frame parent, boolean modal, ArrayList<File> alstImg, int strIndexImage) {
        super(parent, modal);
        frmparent = parent;

        initComponents();
        this.setLocationRelativeTo(null);
        w = imgMain.getWidth();
        h = imgMain.getHeight();
        zoom = 1;
        flag_cut = -1;
        left = 0;
        right = 0;
        leftRo = 0;
        rightRo = 0;
      
       savearr=new ArrayList<SaveArr>();


        arrThumnail = new ArrayList<JLabel>();
        arrThumnail.add(img1);
        arrThumnail.add(img2);
        arrThumnail.add(img3);
        arrThumnail.add(img4);
        arrThumnail.add(img5);
        arrThumnail.add(img6);
        arrThumnail.add(img7);

        this.setTitle("");
        lstImg = alstImg;
        indexImage = strIndexImage;
        if (indexImage > 0) {
            btnPrevious.setEnabled(true);
        }
        if (indexImage < lstImg.size() - 1) {
            btnNext.setEnabled(true);
        }

        ImageIcon imgOriginal = new ImageIcon(lstImg.get(indexImage).getPath());

        ImageIcon ico1 = imageHelper.imageSize(imgOriginal, imgMain);
        imgMain.setIcon(ico1);
        imgRoot = ico1;
        imgUndo=ico1;
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        int tt = indexImage + 1;
        jLabel1.setText(lstImg.get(indexImage).getName() + "  " + sdf.format(lstImg.get(indexImage).lastModified()) + "  " + ico1.getIconWidth() + "x" + ico1.getIconHeight() + " pixels  " + lstImg.get(indexImage).length() + "KB  (" + tt + " of " + lstImg.size() + ")");

        xwidth = ico1.getIconWidth();
        yheight = ico1.getIconHeight();
        Original = imgOriginal;
        if (imgMain.getIcon().getIconWidth() == imgMain.getWidth() || imgMain.getIcon().getIconHeight() == imgMain.getHeight()) {
            SliderZoom.setValue(170);
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1;
        }
        LoadThumn(ico1, imgOriginal);



        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setOpaque(true);


        Pmenu = new JPopupMenu();
        String pathToCopyTo = "images/Exit.png";
        ImageIcon icoCopyTo = new ImageIcon(getClass().getClassLoader().getResource(pathToCopyTo));
        menuItem = new JMenuItem("Copy to", icoCopyTo);


        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                File f = lstImg.get(indexImage);
                JFileChooser saveFile = new JFileChooser();
                saveFile.setAcceptAllFileFilterUsed(false);
                saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".jpg", "jpg"));
                saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".jpeg", "jpeg"));
                saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".png", "png"));
                saveFile.setSelectedFile(f);
                saveFile.setName("Copy to");
                //saveFile.set
                int returnVal = saveFile.showSaveDialog(null);

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = saveFile.getSelectedFile();
                    //    File selectedFile = fileChooser.getSelectedFile();
                    String fileName = null;
                    String EXTENSION = null;
                    try {
                        fileName = file.getCanonicalPath();
                        EXTENSION = saveFile.getFileFilter().getDescription();
                        //   String name = EXTENSION.substring(1);
                    } catch (IOException ex) {
                        Logger.getLogger(ViewPhotos.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    if (!fileName.endsWith(EXTENSION)) {
                        file = new File(fileName + EXTENSION);
                    }
                    if (file.exists()) {
                        JOptionPane.showMessageDialog(null, "File đã tồn tại trong trong thư mục hiện tại");
                    } else {
                        String path = f.getAbsolutePath();
                        Image image = new ImageIcon(path).getImage();
                        BufferedImage bi = imageHelper.toBufferedImage(image);
                        String name = EXTENSION.substring(1);

                        try {
                            ImageIO.write(bi, name, file);
                        } catch (IOException ex) {
                            Logger.getLogger(frmMain.class.getName()).log(Level.SEVERE, null, ex);
                        }


                    }

                }

            }
        });
        Pmenu.add(menuItem);
        /*
         String pathToImageSortBy_cut = "images/cut.png";
         ImageIcon ico_cut = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy_cut));

         menuItem = new JMenuItem("Cut", ico_cut);

         menuItem.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
         File f = lstImg.get(indexImage);
         ImageIcon imgOriginal = new ImageIcon(f.getPath());
         Image a = imgOriginal.getImage();

         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
         ImageSelection selection = new ImageSelection(a);
         clipboard.setContents(selection, null);
         flag_cut = indexImage;
         }
         });
         Pmenu.add(menuItem);
         String pathToImageSortBy_coppy = "images/coppy_32.png";
         ImageIcon ico_coppy = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy_coppy));
         menuItem = new JMenuItem("Copy", ico_coppy);
         menuItem.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
         File f = lstImg.get(indexImage);
         ImageIcon imgOriginal = new ImageIcon(f.getPath());
         Image a = imgOriginal.getImage();

         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
         ImageSelection selection = new ImageSelection(a);
         clipboard.setContents(selection, null);
         flag_cut = -2;
         }
         });
         Pmenu.add(menuItem);
         String pathToImageSortBy_paste = "images/paste_32.png";
         ImageIcon ico_paste = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy_paste));
         menuItem = new JMenuItem("Paste", ico_paste);
         menuItem.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
         if (flag_cut != -1) {
         Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard()
         .getContents(null);

         if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
         try {
         Image img = (Image) t.getTransferData(DataFlavor.imageFlavor);
         ImageIcon ico = new ImageIcon(img);
         imgMain.setIcon(ico);
         imgRoot = ico;


         int i = JOptionPane.showConfirmDialog(null, "Bạn muốn lưu???", "Comfirm ", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
         if (i == 0) {
         String EXTENSION;//= ".png";
         // String FORMAT_NAME = "png";
         //      LayoutFileFilter SAVE_AS_IMAGE = new LayoutFileFilter("PNG Image Format", EXTENSION, true);
         BufferedImage bi = toBufferedImage(img);
         //  BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);

         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setAcceptAllFileFilterUsed(false);
         fileChooser.addChoosableFileFilter(new FileNameExtensionFilter(".jpg", "jpg"));
         fileChooser.addChoosableFileFilter(new FileNameExtensionFilter(".jpeg", "jpeg"));
         fileChooser.addChoosableFileFilter(new FileNameExtensionFilter(".png", "png"));
         //     ExtensionFileFilter pFilter = new ExtensionFileFilter(SAVE_AS_IMAGE);
         //       fileChooser.setFileFilter(pFilter);

         int status = fileChooser.showSaveDialog(null);

         if (status == JFileChooser.APPROVE_OPTION) {
         File selectedFile = fileChooser.getSelectedFile();

         String fileName = selectedFile.getCanonicalPath();
         EXTENSION = fileChooser.getFileFilter().getDescription();
         String name = EXTENSION.substring(1);

         if (!fileName.endsWith(EXTENSION)) {
         selectedFile = new File(fileName + EXTENSION);
         }
         //  JOptionPane.showMessageDialog(null, EXTENSION);
         ImageIO.write(bi, name, selectedFile);
         if (flag_cut >= 0) {
         File file = lstImg.get(flag_cut);
         if (file.exists()) {
         file.delete();

         lstImg.remove(flag_cut);
         //  LoadThumn(ico1, imgOriginal);
         flag_cut = -1;
         }
         }
         //đưa về cuối mảng
         //     indexImage = lstImg.size() - 1;
         //    btnNext.setEnabled(false);
         } else {
         System.out.println("File access cancelled by user.");
         }



         } else {
         System.out.println("File access cancelled by user.");
         }



         } catch (UnsupportedFlavorException ex) {
         Logger.getLogger(ViewPhotos.class.getName()).log(Level.SEVERE, null, ex);
         } catch (IOException ex) {
         Logger.getLogger(ViewPhotos.class.getName()).log(Level.SEVERE, null, ex);
         }
         }

         } else {
         JOptionPane.showMessageDialog(null, "Bạn chưa copy ảnh");
         }
         }
         });
         * */
        Pmenu.add(menuItem);
        String pathToImageSortBy_Delete = "images/delete_32.png";
        ImageIcon ico_Delete = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy_Delete));
        menuItem = new JMenuItem("Delele", ico_Delete);
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                File file = lstImg.get(indexImage);
                if (file.exists()) {
                    file.delete();

                    lstImg.remove(indexImage);
                    if (indexImage == lstImg.size()) {
                        indexImage--;
                    }
                    File f = lstImg.get(indexImage);
                    ImageIcon imgOriginal = new ImageIcon(f.getPath());
                    ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
                    img4.setIcon(icothumnail);

                    ImageIcon ico1;
                    int indexImg = indexImage - 3;
                    for (int i = 0; i < 3; i++) {
                        if (indexImg < 0) {
                            icothumnail = new ImageIcon("");
                            arrThumnail.get(i).setIcon(icothumnail);
                            arrThumnail.get(i).setName(null);
                            arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                        } else {
                            ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                            icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                            arrThumnail.get(i).setIcon(icothumnail);
                            arrThumnail.get(i).setName(Integer.toString(indexImg));
                            arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                        }
                        indexImg++;
                    }
                    indexImg = indexImage + 1;
                    for (int i = 4; i < 7; i++) {
                        if (indexImg >= lstImg.size()) {
                            icothumnail = new ImageIcon("");
                            arrThumnail.get(i).setIcon(icothumnail);
                            arrThumnail.get(i).setName(null);
                            arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                        } else {
                            ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                            icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                            arrThumnail.get(i).setIcon(icothumnail);
                            arrThumnail.get(i).setName(Integer.toString(indexImg));
                            arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                        }
                        indexImg++;
                    }


                    ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
                    imgMain.setIcon(ico);
                    int tt = indexImage + 1;
                    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                    jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + tt + " of " + lstImg.size() + ")");

                    xwidth = ico.getIconWidth();
                    yheight = ico.getIconHeight();
                    Original = imgOriginal;
                    if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                        SliderZoom.setValue(170);
                        btnZoomIn.setEnabled(false);
                        jMenuItem4.setEnabled(false);
                        zoom = 1;
                    } else {
                        btnZoomIn.setEnabled(true);
                        jMenuItem4.setEnabled(true);
                    }

                    if (indexImage == lstImg.size() - 1) {
                        btnNext.setEnabled(false);
                    }



                }
            }
        });
        Pmenu.add(menuItem);/*
         String pathToImageSortBy_LocalDisk = "images/refresh_32.png";
         ImageIcon ico_LocalDisk = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy_LocalDisk));
         menuItem  = new JMenuItem("Local is Disk", ico_LocalDisk);

         menuItem.addActionListener ( 
         new ActionListener() {
         @Override
         public void actionPerformed
         (ActionEvent e
                
         ) {
         System.out.println("Popup menu item ["
         + e.getActionCommand() + "] was pressed.");
         }
         }

         );
         Pmenu.add (menuItem);
         */
        imgMain.addMouseListener(
                new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent Me) {
                if (Me.isPopupTrigger()) {
                    Pmenu.show(Me.getComponent(), Me.getX(), Me.getY());
                }
            }
        });
        frmparent.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXPanel2 = new org.jdesktop.swingx.JXPanel();
        jPanel1 = new javax.swing.JPanel();
        imgMain = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jXButton4 = new org.jdesktop.swingx.JXButton();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        btnRotateLeft = new javax.swing.JButton();
        btnRotateRight = new javax.swing.JButton();
        SliderZoom = new javax.swing.JSlider();
        btnFullScreen = new javax.swing.JButton();
        btnZoomIn = new org.jdesktop.swingx.JXButton();
        btnZoomOut = new org.jdesktop.swingx.JXButton();
        jXPanel3 = new org.jdesktop.swingx.JXPanel();
        btnBack = new javax.swing.JButton();
        btnSlideShow = new javax.swing.JButton();
        btnPrevious = new javax.swing.JButton();
        btnNext = new javax.swing.JButton();
        jXLabel2 = new org.jdesktop.swingx.JXLabel();
        btnTru = new org.jdesktop.swingx.JXButton();
        lbDislayTime = new javax.swing.JLabel();
        btnCong = new org.jdesktop.swingx.JXButton();
        jXPanel4 = new org.jdesktop.swingx.JXPanel();
        img1 = new javax.swing.JLabel();
        img2 = new javax.swing.JLabel();
        img3 = new javax.swing.JLabel();
        img4 = new javax.swing.JLabel();
        img5 = new javax.swing.JLabel();
        img6 = new javax.swing.JLabel();
        img7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        SliderBlur = new javax.swing.JSlider();
        jPanel3 = new javax.swing.JPanel();
        btnPrint = new org.jdesktop.swingx.JXButton();
        btnSendMail = new org.jdesktop.swingx.JXButton();
        jPanel4 = new javax.swing.JPanel();
        SliderBrightness = new javax.swing.JSlider();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu10 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem36 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu8 = new javax.swing.JMenu();
        jMenuItem23 = new javax.swing.JMenuItem();
        jMenuItem24 = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu12 = new javax.swing.JMenu();
        jSeparator9 = new javax.swing.JPopupMenu.Separator();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu15 = new javax.swing.JMenu();
        jMenuItem43 = new javax.swing.JMenuItem();
        jMenuItem44 = new javax.swing.JMenuItem();
        jMenu16 = new javax.swing.JMenu();
        jMenuItem45 = new javax.swing.JMenuItem();
        jMenuItem46 = new javax.swing.JMenuItem();
        jMenu14 = new javax.swing.JMenu();
        jSeparator17 = new javax.swing.JPopupMenu.Separator();
        jMenuItem41 = new javax.swing.JMenuItem();
        jMenuItem42 = new javax.swing.JMenuItem();
        jMenu11 = new javax.swing.JMenu();
        jMenuItem30 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Photos");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(153, 153, 153));

        imgMain.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imgMain.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/view_tree.png"))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(imgMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(imgMain, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel1.setBackground(new java.awt.Color(204, 204, 255));
        jLabel1.setForeground(new java.awt.Color(153, 153, 255));
        jLabel1.setText("Hiển Thị Tên Ảnh");

        jXButton4.setText("A|A");
        jXButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton4ActionPerformed(evt);
            }
        });

        jXPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Process"));

        btnRotateLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/XoayTrai.png"))); // NOI18N
        btnRotateLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRotateLeftActionPerformed(evt);
            }
        });

        btnRotateRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/XoayPhai.png"))); // NOI18N
        btnRotateRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRotateRightActionPerformed(evt);
            }
        });

        SliderZoom.setMajorTickSpacing(10);
        SliderZoom.setMaximum(170);
        SliderZoom.setMinimum(30);
        SliderZoom.setValue(100);
        SliderZoom.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                SliderZoomMouseReleased(evt);
            }
        });
        SliderZoom.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SliderZoomStateChanged(evt);
            }
        });

        btnFullScreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Window-Resize-icon.png"))); // NOI18N
        btnFullScreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFullScreenActionPerformed(evt);
            }
        });

        btnZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/icon_ZoomIn.png"))); // NOI18N
        btnZoomIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnZoomInActionPerformed(evt);
            }
        });

        btnZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/icon_ZoomOut.png"))); // NOI18N
        btnZoomOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnZoomOutActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel1Layout = new javax.swing.GroupLayout(jXPanel1);
        jXPanel1.setLayout(jXPanel1Layout);
        jXPanel1Layout.setHorizontalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addComponent(btnRotateLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnRotateRight, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addComponent(btnZoomOut, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SliderZoom, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnZoomIn, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addComponent(btnFullScreen, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19))
        );
        jXPanel1Layout.setVerticalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnRotateLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(btnRotateRight, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnZoomOut, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel1Layout.createSequentialGroup()
                                .addComponent(SliderZoom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(11, 11, 11))
                            .addComponent(btnFullScreen, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnZoomIn, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );

        btnBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Log-Out-icon.png"))); // NOI18N
        btnBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBackActionPerformed(evt);
            }
        });

        btnSlideShow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/play.png"))); // NOI18N
        btnSlideShow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSlideShowActionPerformed(evt);
            }
        });

        btnPrevious.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/left-icon.png"))); // NOI18N
        btnPrevious.setEnabled(false);
        btnPrevious.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPreviousActionPerformed(evt);
            }
        });

        btnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/right-icon.png"))); // NOI18N
        btnNext.setEnabled(false);
        btnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextActionPerformed(evt);
            }
        });

        jXLabel2.setText("Thời Gian Hiển Thị ");

        btnTru.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Tru.png"))); // NOI18N
        btnTru.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTruActionPerformed(evt);
            }
        });

        lbDislayTime.setText("3");

        btnCong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Cong.png"))); // NOI18N
        btnCong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCongActionPerformed(evt);
            }
        });

        jXPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 255)));
        jXPanel4.setPreferredSize(new java.awt.Dimension(268, 28));
        jXPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        img1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img1.setPreferredSize(new java.awt.Dimension(28, 28));
        img1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img1MouseClicked(evt);
            }
        });
        jXPanel4.add(img1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, 40, 40));

        img2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img2.setPreferredSize(new java.awt.Dimension(28, 28));
        img2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img2MouseClicked(evt);
            }
        });
        jXPanel4.add(img2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 0, 40, 40));

        img3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img3.setPreferredSize(new java.awt.Dimension(28, 28));
        img3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img3MouseClicked(evt);
            }
        });
        jXPanel4.add(img3, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 0, 40, 40));

        img4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img4.setPreferredSize(new java.awt.Dimension(28, 28));
        img4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img4MouseClicked(evt);
            }
        });
        jXPanel4.add(img4, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 0, 40, 40));

        img5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img5.setPreferredSize(new java.awt.Dimension(28, 28));
        img5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img5MouseClicked(evt);
            }
        });
        jXPanel4.add(img5, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 0, 40, 40));

        img6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img6.setPreferredSize(new java.awt.Dimension(28, 28));
        img6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img6MouseClicked(evt);
            }
        });
        jXPanel4.add(img6, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 0, 40, 40));

        img7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img7.setPreferredSize(new java.awt.Dimension(28, 28));
        img7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                img7MouseClicked(evt);
            }
        });
        jXPanel4.add(img7, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 0, 40, 40));

        javax.swing.GroupLayout jXPanel3Layout = new javax.swing.GroupLayout(jXPanel3);
        jXPanel3.setLayout(jXPanel3Layout);
        jXPanel3Layout.setHorizontalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnBack)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 168, Short.MAX_VALUE)
                .addComponent(btnPrevious, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jXPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14)
                .addComponent(btnNext, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addComponent(btnTru, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(lbDislayTime, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(btnCong, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(btnSlideShow, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(465, 465, 465))
        );
        jXPanel3Layout.setVerticalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(jXPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addComponent(btnPrevious, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jXPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel3Layout.createSequentialGroup()
                        .addGap(0, 2, Short.MAX_VALUE)
                        .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnBack, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(btnNext, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jXPanel3Layout.createSequentialGroup()
                                    .addGap(4, 4, 4)
                                    .addComponent(btnSlideShow, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel3Layout.createSequentialGroup()
                                    .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(btnCong, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnTru, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lbDislayTime, javax.swing.GroupLayout.Alignment.TRAILING)))))))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Blur"));

        SliderBlur.setMajorTickSpacing(100);
        SliderBlur.setMaximum(200);
        SliderBlur.setMinorTickSpacing(100);
        SliderBlur.setPaintTicks(true);
        SliderBlur.setValue(200);
        SliderBlur.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                SliderBlurMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(SliderBlur, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(SliderBlur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Share"));

        btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/In_Anh.png"))); // NOI18N
        btnPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrintActionPerformed(evt);
            }
        });

        btnSendMail.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Mail_images.png"))); // NOI18N
        btnSendMail.setPreferredSize(new java.awt.Dimension(97, 50));
        btnSendMail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSendMailActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(btnSendMail, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(btnPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnPrint, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(btnSendMail, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(3, 3, 3))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Brightness"));

        SliderBrightness.setMajorTickSpacing(10);
        SliderBrightness.setMaximum(200);
        SliderBrightness.setMinorTickSpacing(10);
        SliderBrightness.setPaintTicks(true);
        SliderBrightness.setValue(100);
        SliderBrightness.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                SliderBrightnessMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(SliderBrightness, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(SliderBrightness, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 9, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jXPanel2Layout = new javax.swing.GroupLayout(jXPanel2);
        jXPanel2.setLayout(jXPanel2Layout);
        jXPanel2Layout.setHorizontalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(180, 180, 180))
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jXButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1363, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jXPanel2Layout.setVerticalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addComponent(jXButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addGap(716, 716, 716))
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addComponent(jXPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        jMenu10.setText("File");

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setText("Save");
        jMenuItem3.setEnabled(false);
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem3);

        jMenuItem6.setText("Save As");
        jMenuItem6.setEnabled(false);
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem6);

        jMenuItem9.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem9.setText("Copy To");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem9);

        jMenuItem10.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem10.setText("Delete");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem10);

        jMenuItem36.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem36.setText("Exit");
        jMenuItem36.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem36ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem36);

        jMenuBar1.add(jMenu10);

        jMenu2.setText("View");

        jMenu6.setText("View Photo");

        jMenuItem1.setText("Full Photo");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem1);

        jMenuItem2.setText("Live Show");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem2);

        jMenu2.add(jMenu6);

        jMenu8.setText("Rotate Photo");

        jMenuItem23.setText("Right Rotate");
        jMenuItem23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem23ActionPerformed(evt);
            }
        });
        jMenu8.add(jMenuItem23);

        jMenuItem24.setText("Left Rotate");
        jMenuItem24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem24ActionPerformed(evt);
            }
        });
        jMenu8.add(jMenuItem24);

        jMenu2.add(jMenu8);
        jMenu2.add(jSeparator8);

        jMenu4.setText("Zoom");

        jMenuItem4.setText("Up");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem4);

        jMenuItem5.setText("Down");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem5);

        jMenu2.add(jMenu4);

        jMenuBar1.add(jMenu2);

        jMenu12.setText("Edit");
        jMenu12.add(jSeparator9);

        jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem7.setText("Undo all edits");
        jMenuItem7.setEnabled(false);
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu12.add(jMenuItem7);

        jMenu15.setText("Blurring Photo");

        jMenuItem43.setText("Up");
        jMenuItem43.setEnabled(false);
        jMenuItem43.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem43ActionPerformed(evt);
            }
        });
        jMenu15.add(jMenuItem43);

        jMenuItem44.setText("Down");
        jMenuItem44.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem44ActionPerformed(evt);
            }
        });
        jMenu15.add(jMenuItem44);

        jMenu12.add(jMenu15);

        jMenu16.setText("Brightness Photo");

        jMenuItem45.setText("Up");
        jMenuItem45.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem45ActionPerformed(evt);
            }
        });
        jMenu16.add(jMenuItem45);

        jMenuItem46.setText("Down");
        jMenuItem46.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem46ActionPerformed(evt);
            }
        });
        jMenu16.add(jMenuItem46);

        jMenu12.add(jMenu16);

        jMenuBar1.add(jMenu12);

        jMenu14.setText("Share");
        jMenu14.add(jSeparator17);

        jMenuItem41.setText("Print Image");
        jMenuItem41.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem41ActionPerformed(evt);
            }
        });
        jMenu14.add(jMenuItem41);

        jMenuItem42.setText("Mail Image");
        jMenuItem42.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem42ActionPerformed(evt);
            }
        });
        jMenu14.add(jMenuItem42);

        jMenuBar1.add(jMenu14);

        jMenu11.setText("Help");

        jMenuItem30.setText("About us");
        jMenuItem30.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem30ActionPerformed(evt);
            }
        });
        jMenu11.add(jMenuItem30);

        jMenuBar1.add(jMenu11);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 1349, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 666, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public static boolean hasAlpha(Image image) {
        // If buffered image, the color model is readily available
        if (image instanceof BufferedImage) {
            BufferedImage bimage = (BufferedImage) image;
            return bimage.getColorModel().hasAlpha();
        }

        // Use a pixel grabber to retrieve the image's color model;
        // grabbing a single pixel is usually sufficient
        PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
        try {
            pg.grabPixels();
        } catch (InterruptedException e) {
        }

        // Get the image's color model
        ColorModel cm = pg.getColorModel();
        return cm.hasAlpha();
    }

    public static BufferedImage toBufferedImage(Image image) {
        if (image instanceof BufferedImage) {
            return (BufferedImage) image;
        }

        // This code ensures that all the pixels in the image are loaded
        image = new ImageIcon(image).getImage();

        // Determine if the image has transparent pixels; for this method's
        // implementation, see e661 Determining If an Image Has Transparent Pixels
        boolean hasAlpha = hasAlpha(image);

        // Create a buffered image with a format that's compatible with the screen
        BufferedImage bimage = null;
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        try {
            // Determine the type of transparency of the new buffered image
            int transparency = Transparency.OPAQUE;
            if (hasAlpha) {
                transparency = Transparency.BITMASK;
            }

            // Create the buffered image
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gs.getDefaultConfiguration();
            bimage = gc.createCompatibleImage(
                    image.getWidth(null), image.getHeight(null), transparency);
        } catch (HeadlessException e) {
            // The system does not have a screen
        }

        if (bimage == null) {
            // Create a buffered image using the default color model
            int type = BufferedImage.TYPE_INT_RGB;

            if (hasAlpha) {
                //     type = BufferedImage.TYPE_INT_ARGB;
            }
            bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
        }

        // Copy image to buffered image
        Graphics g = bimage.createGraphics();

        // Paint the image onto the buffered image
        g.drawImage(image, 0, 0, null);
        g.dispose();

        return bimage;
    }

    public static GraphicsConfiguration getDefaultConfiguration() {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        return gd.getDefaultConfiguration();
    }

    public static BufferedImage tilt(BufferedImage image, double angle) {
        double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
        int w1 = image.getWidth(), h1 = image.getHeight();
        int neww = (int) Math.floor(w1 * cos + h1 * sin), newh = (int) Math.floor(h1 * cos + w1 * sin);
        GraphicsConfiguration gc = getDefaultConfiguration();
        BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.OPAQUE);
        Graphics2D g = result.createGraphics();
        g.translate((neww - w1) / 2, (newh - h1) / 2);
        g.rotate(angle, w1 / 2, h1 / 2);
        g.drawRenderedImage(image, null);
        g.dispose();
        return result;
    }

    public static Image rotateImage(Image img, double degree) {
        BufferedImage bufImg = toBufferedImage(img);
        double angle = Math.toRadians(degree);

        return tilt(bufImg, angle);
    }

    private void img1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img1MouseClicked
        // TODO add your handling code here:
        String location = img1.getName();
        if (location != null && !"".equals(location)) {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
            jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            Original = ico;
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }
            if (img2.getName() != null && !"".equals(img2.getName())) {
                btnNext.setEnabled(true);
            }
            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            }
            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }
        }
    }//GEN-LAST:event_img1MouseClicked

    private void LoadThumn(ImageIcon ico1, ImageIcon imgOriginal) {
        ImageIcon thumnail = imageHelper.imageSize(imgOriginal, img4);

        img4.setIcon(thumnail);
        img4.setName(Integer.toString(indexImage));
        img4.setBorder(BorderFactory.createLineBorder(Color.BLUE, 1));

        int indexImg = 3;

        for (int i = indexImage - 1; i > indexImage - 4 && i >= 0; i--) {
            indexImg--;
            ico1 = new ImageIcon(lstImg.get(i).getPath());
            thumnail = imageHelper.imageSize(ico1, arrThumnail.get(indexImg));
            arrThumnail.get(indexImg).setIcon(thumnail);
            arrThumnail.get(indexImg).setName(Integer.toString(i));
            arrThumnail.get(indexImg).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
        }
        indexImg = 3;

        for (int i = indexImage + 1; i < indexImage + 4 && i < lstImg.size(); i++) {
            indexImg++;
            ico1 = new ImageIcon(lstImg.get(i).getPath());
            thumnail = imageHelper.imageSize(ico1, arrThumnail.get(indexImg));
            arrThumnail.get(indexImg).setIcon(thumnail);
            arrThumnail.get(indexImg).setName(Integer.toString(i));
            arrThumnail.get(indexImg).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
        }

    }
    private void img2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img2MouseClicked
        // TODO add your handling code here:
        String location = img2.getName();
        if (location != null && !"".equals(location)) {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }
            if (img3.getName() != null && !"".equals(img3.getName())) {
                btnNext.setEnabled(true);
            }

            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }
            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }
        }
    }//GEN-LAST:event_img2MouseClicked

    private void img3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img3MouseClicked
        // TODO add your handling code here:
        String location = img3.getName();
        if (location != null && !"".equals(location)) {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }

            if (img4.getName() != null && !"".equals(img4.getName())) {
                btnNext.setEnabled(true);
            }

            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }
            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }
        }
    }//GEN-LAST:event_img3MouseClicked

    private void img4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img4MouseClicked
        // TODO add your handling code here:
        String location = img4.getName();
        if (location != null && !"".equals(location)) {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }
            if (img5.getName() != null && !"".equals(img5.getName())) {
                btnNext.setEnabled(true);

            }
            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }
            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }
        }
    }//GEN-LAST:event_img4MouseClicked

    private void img5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img5MouseClicked
        // TODO add your handling code here:
        String location = img5.getName();
        if (location != null && location != "") {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }
            if (img6.getName() != null && !"".equals(img6.getName())) {
                btnNext.setEnabled(true);
            }
            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }
            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }
        }
    }//GEN-LAST:event_img5MouseClicked

    private void img6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img6MouseClicked
        // TODO add your handling code here:
        String location = img6.getName();
        if (location != null && location != "") {
              SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
             imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            btnZoomOut.setEnabled(true);
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;

            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }
            if (img7.getName() != null && !"".equals(img7.getName())) {
                btnNext.setEnabled(true);
            }
            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }

            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }

        }
    }//GEN-LAST:event_img6MouseClicked

    private void jXButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton4ActionPerformed

    private void btnFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFullScreenActionPerformed
        // TODO add your handling code here:

        SlideShow_FullScreen ss = new SlideShow_FullScreen(new ImageIcon(lstImg.get(indexImage).getPath()), this);
        ss.LoadImage();
    }//GEN-LAST:event_btnFullScreenActionPerformed

    private void img7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_img7MouseClicked
        // TODO add your handling code here:
        String location = img7.getName();
        if (location != null && !"".equals(location)) {
  SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
            imgRo=null;
            if (imgsave != null) {
                SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
                savearr.add(a);
                imgsave = null;
            }
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
             jMenuItem7.setEnabled(false);
            btnZoomOut.setEnabled(true);
            left = 0;
            right = 0;
            leftRo = 0;
            rightRo = 0;
            int l = Integer.parseInt(location);
            File f = lstImg.get(l);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            imgRoot = ico;
            imgUndo=ico;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + location + " of " + lstImg.size() + ")");

            indexImage = l;
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);


            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }



            this.SliderZoom.setValue(100);
            zoom = 1;
            Original = ico;
            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }

            if (indexImage == 0) {
                btnPrevious.setEnabled(false);
            } else {
                btnPrevious.setEnabled(true);
            }
            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }

        }
    }//GEN-LAST:event_img7MouseClicked

    private void btnTruActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTruActionPerformed
        // TODO add your handling code here:
        if (iSecond > 1) {
            iSecond--;
            lbDislayTime.setText(Integer.toString(iSecond));
        }
    }//GEN-LAST:event_btnTruActionPerformed

    private void btnCongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCongActionPerformed
        // TODO add your handling code here:
        if (iSecond < 15) {
            iSecond++;
            lbDislayTime.setText(Integer.toString(iSecond));
        }
    }//GEN-LAST:event_btnCongActionPerformed

    private void btnSlideShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSlideShowActionPerformed
        // TODO add your handling code here:
        int time = Integer.parseInt(lbDislayTime.getText());
        SlideShow_FullScreen ss = new SlideShow_FullScreen(lstImg, this, indexImage, time);
        ss.LoadImage();
    }//GEN-LAST:event_btnSlideShowActionPerformed

    private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextActionPerformed
        // TODO add your handling code here:
          SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
         imgRo=null;
        if (imgsave != null) {
              SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
            savearr.add(a);
            imgsave = null;
        }
        jMenuItem3.setEnabled(false);
        jMenuItem6.setEnabled(false);
         jMenuItem7.setEnabled(false);
        left = 0;
        right = 0;
        leftRo = 0;
        rightRo = 0;
        this.SliderZoom.setValue(100);
        zoom = 1;//set cho zoom +-
        btnPrevious.setEnabled(true);
        indexImage += 1;
        File f = lstImg.get(indexImage);
        ImageIcon imgOriginal = new ImageIcon(f.getPath());
        ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
        img4.setIcon(icothumnail);

        ImageIcon ico1;
        int indexImg = indexImage - 3;
        for (int i = 0; i < 3; i++) {
            if (indexImg < 0) {
                icothumnail = new ImageIcon("");
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(null);
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
            } else {
                ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(Integer.toString(indexImg));
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
            }
            indexImg++;
        }
        indexImg = indexImage + 1;
        for (int i = 4; i < 7; i++) {
            if (indexImg >= lstImg.size()) {
                icothumnail = new ImageIcon("");
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(null);
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
            } else {
                ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(Integer.toString(indexImg));
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
            }
            indexImg++;
        }


        ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
        imgMain.setIcon(ico);
        imgRoot=ico;
        imgUndo=ico;
        int tt = indexImage + 1;
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + tt + " of " + lstImg.size() + ")");

        xwidth = ico.getIconWidth();
        yheight = ico.getIconHeight();
        Original = imgOriginal;
        if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
            SliderZoom.setValue(170);
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1;
        } else {
            btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }

        if (indexImage == lstImg.size() - 1) {
            btnNext.setEnabled(false);
        }

        /*
         if (imgthumn == 6 && indexImage < lstImg.size() - 1) {
         for (int i = 0; i < 6; i++) {
         arrThumnail.get(i).setIcon(arrThumnail.get(i + 1).getIcon());
         arrThumnail.get(i).setName(arrThumnail.get(i + 1).getName());
         }
         ImageIcon ico1 = new ImageIcon(lstImg.get(indexImage + 1).getPath());
         ImageIcon icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(6));
         arrThumnail.get(6).setIcon(icothumnail);
         arrThumnail.get(6).setName(Integer.toString(indexImage + 1));
         arrThumnail.get(6).setBorder(BorderFactory.createLineBorder(Color.BLUE, 1));
         } else {
         arrThumnail.get(imgthumn).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
         imgthumn++;
         arrThumnail.get(imgthumn).setBorder(BorderFactory.createLineBorder(Color.BLUE, 1));
         }
         indexImage += 1;
         //set lại icon cho label
         File f = lstImg.get(indexImage);
         ImageIcon imgOriginal = new ImageIcon(f.getPath());
         ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
         imgMain.setIcon(ico);
         imgRoot = ico;
         if (indexImage == lstImg.size() - 1) {
         btnNext.setEnabled(false);
         }

         int tt = indexImage + 1;
         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
         jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + tt + " of " + lstImg.size() + ")");
         xwidth = ico.getIconWidth();
         yheight = ico.getIconHeight();
         Original = imgOriginal;
         if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
         SliderZoom.setValue(170);
         btnZoomIn.setEnabled(false);
         jMenuItem4.setEnabled(false);
         zoom = 1;
         } else {
         btnZoomIn.setEnabled(true);
         jMenuItem4.setEnabled(true);
         }

         if (indexImage == lstImg.size() - 1) {
         btnNext.setEnabled(false);
         }
         */
    }//GEN-LAST:event_btnNextActionPerformed

    private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousActionPerformed
        // TODO add your handling code here:
        SliderBrightness.setValue(100);
        SliderBlur.setValue(200);
        imgRo=null;
        if (imgsave != null) {
            SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
            savearr.add(a);
            imgsave = null;
        }
        jMenuItem3.setEnabled(false);
        jMenuItem6.setEnabled(false);
         jMenuItem7.setEnabled(false);
        left = 0;
        right = 0;
        leftRo = 0;
        rightRo = 0;
        this.SliderZoom.setValue(100);
        zoom = 1;//set cho zoom
        btnNext.setEnabled(true);

        indexImage -= 1;
        File f = lstImg.get(indexImage);
        ImageIcon imgOriginal = new ImageIcon(f.getPath());

        ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
        img4.setIcon(icothumnail);


        ImageIcon ico1;
        int indexImg = indexImage - 3;
        for (int i = 0; i < 3; i++) {
            if (indexImg < 0) {
                icothumnail = new ImageIcon("");
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(null);
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
            } else {
                ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(Integer.toString(indexImg));
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
            }
            indexImg++;
        }
        indexImg = indexImage + 1;
        for (int i = 4; i < 7; i++) {
            if (indexImg >= lstImg.size()) {
                icothumnail = new ImageIcon("");
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(null);
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
            } else {
                ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                arrThumnail.get(i).setIcon(icothumnail);
                arrThumnail.get(i).setName(Integer.toString(indexImg));
                arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
            }
            indexImg++;
        }

        ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
        imgMain.setIcon(ico);
        imgRoot=ico;
        imgUndo=ico;

        int tt = indexImage + 1;
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + tt + " of " + lstImg.size() + ")");

        xwidth = ico.getIconWidth();
        yheight = ico.getIconHeight();
        Original = imgOriginal;
        if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
            SliderZoom.setValue(170);
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1;
        } else {
            btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }

        if (indexImage == 0) {
            btnPrevious.setEnabled(false);
        }
    }//GEN-LAST:event_btnPreviousActionPerformed

    private void btnRotateLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRotateLeftActionPerformed
        // TODO add your handling code here:
        jMenuItem3.setEnabled(true);
        jMenuItem6.setEnabled(true);
         jMenuItem7.setEnabled(true);
        ImageIcon ico2 = null;
        Image ico = null;
        if (imgRo == null) {
            if (left == 0) {
                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (right == 0) {
                    ico = rotateImage(a, -90);
                } else if (right == 1) {
                    ico = a;
                } else if (right == 2) {
                    ico = rotateImage(a, 90);
                } else {
                    ico = rotateImage(a, 180);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                left = 1;
            } else if (left == 1) {
                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (right == 0) {
                    ico = rotateImage(a, -180);
                } else if (right == 1) {
                    ico = rotateImage(a, -90);
                } else if (right == 2) {
                    ico = a;
                } else {
                    ico = rotateImage(a, 90);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                left = 2;
            } else if (left == 2) {
                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (right == 0) {
                    ico = rotateImage(a, -270);
                } else if (right == 1) {
                    ico = rotateImage(a, -180);
                } else if (right == 2) {
                    ico = rotateImage(a, -90);
                } else {
                    ico = a;
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                left = 3;
            } else {
                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (right == 0) {
                    ico = rotateImage(a, -360);
                } else if (right == 1) {
                    ico = rotateImage(a, -270);
                } else if (right == 2) {
                    ico = rotateImage(a, -180);
                } else {
                    ico = rotateImage(a, -90);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                left = 0;
            }

        } else {
            imgRo1 = imgRo;
            if (leftRo == 0) {

                if (rightRo == 0) {
                    ico = rotateImage(imgRo, -90);
                } else if (rightRo == 1) {
                    ico = imgRo;
                } else if (rightRo == 2) {
                    ico = rotateImage(imgRo, 90);
                } else {
                    ico = rotateImage(imgRo, 180);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                leftRo = 1;
            } else {
                if (leftRo == 1) {
                    if (rightRo == 0) {
                        ico = rotateImage(imgRo1, -180);
                    } else if (rightRo == 1) {
                        ico = rotateImage(imgRo1, -90);
                    } else if (rightRo == 2) {
                        ico = imgRo1;
                    } else {
                        ico = rotateImage(imgRo1, 90);
                    }
                    // ico = rotateImage(imgRo1, -90);
                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    leftRo = 2;
                } else if (leftRo == 2) {
                    if (rightRo == 0) {
                        ico = rotateImage(imgRo1, -270);
                    } else if (rightRo == 1) {
                        ico = rotateImage(imgRo1, -180);
                    } else if (rightRo == 2) {
                        ico = rotateImage(imgRo1, -90);
                    } else {
                        ico = imgRo1;
                    }
                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    leftRo = 3;
                } else if (leftRo == 3) {
                    if (rightRo == 0) {
                        ico = rotateImage(imgRo1, -360);
                    } else if (rightRo == 1) {
                        ico = rotateImage(imgRo1, -270);
                    } else if (rightRo == 2) {
                        ico = rotateImage(imgRo1, -180);
                    } else {
                        ico = rotateImage(imgRo1, -90);
                    }
                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    leftRo = 0;
                }

            }

        }

        imgMain.setIcon(ico2);
        imgRoot = ico2;
        imgsave = ico;
       

        this.SliderZoom.setValue(100);
        zoom = 1;

        Original = ico2;
        xwidth = ico2.getIconWidth();
        yheight = ico2.getIconHeight();
        if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
            SliderZoom.setValue(170);
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1;
        } else {
            btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }
    }//GEN-LAST:event_btnRotateLeftActionPerformed

    private void btnRotateRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRotateRightActionPerformed
        // TODO add your handling code here:
        jMenuItem3.setEnabled(true);
        jMenuItem6.setEnabled(true);
         jMenuItem7.setEnabled(true);
        Image ico = null;
        ImageIcon ico2 = null;
        if (imgRo == null) {
            if (right == 0) {

                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (left == 0) {
                    ico = rotateImage(a, 90);
                } else if (left == 1) {
                    ico = a;
                } else if (left == 2) {
                    ico = rotateImage(a, -90);
                } else {
                    ico = rotateImage(a, -180);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                right = 1;
            } else if (right == 1) {

                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (left == 0) {
                    ico = rotateImage(a, 180);
                } else if (left == 1) {
                    ico = rotateImage(a, 90);
                } else if (left == 2) {
                    ico = a;
                } else {
                    ico = rotateImage(a, -90);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                right = 2;
            } else if (right == 2) {

                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (left == 0) {
                    ico = rotateImage(a, 270);
                } else if (left == 1) {
                    ico = rotateImage(a, 180);
                } else if (left == 2) {
                    ico = rotateImage(a, 90);
                } else {
                    ico = a;
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                right = 3;
            } else {

                File f = lstImg.get(indexImage);
                ImageIcon ico1 = new ImageIcon(f.getPath());
                Image a = ico1.getImage();
                if (left == 0) {
                    ico = rotateImage(a, 360);
                } else if (left == 1) {
                    ico = rotateImage(a, 270);
                } else if (left == 2) {
                    ico = rotateImage(a, 180);
                } else {
                    ico = rotateImage(a, 90);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                right = 0;
            }

        } else {
            imgRo1 = imgRo;
            if (rightRo == 0) {
                if (leftRo == 0) {
                    ico = rotateImage(imgRo, 90);
                } else if (leftRo == 1) {
                    ico = imgRo;
                } else if (leftRo == 2) {
                    ico = rotateImage(imgRo, -90);
                } else if (leftRo == 3) {
                    ico = rotateImage(imgRo, -180);
                }
                ImageIcon ico3 = new ImageIcon(ico);
                ico2 = imageHelper.imageSize(ico3, imgMain);
                rightRo = 1;
            } else {
                if (rightRo == 1) {
                    if (leftRo == 0) {
                        ico = rotateImage(imgRo1, 180);
                    } else if (leftRo == 1) {
                        ico = rotateImage(imgRo1, 90);
                    } else if (leftRo == 2) {
                        ico = imgRo1;
                    } else if (leftRo == 3) {
                        ico = imgRo1;
                    }

                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    rightRo = 2;
                } else if (rightRo == 2) {
                    if (leftRo == 0) {
                        ico = rotateImage(imgRo1, 270);
                    } else if (leftRo == 1) {
                        ico = rotateImage(imgRo1, 180);
                    } else if (leftRo == 2) {
                        ico = rotateImage(imgRo1, 90);
                    } else if (leftRo == 3) {
                        ico = imgRo1;
                    }
                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    rightRo = 3;
                } else if (rightRo == 3) {
                    if (leftRo == 0) {
                        ico = rotateImage(imgRo1, 360);
                    } else if (leftRo == 1) {
                        ico = rotateImage(imgRo1, 270);
                    } else if (leftRo == 2) {
                        ico = rotateImage(imgRo1, 180);
                    } else if (leftRo == 3) {
                        ico = rotateImage(imgRo1, 90);
                    }
                    ImageIcon ico3 = new ImageIcon(ico);
                    ico2 = imageHelper.imageSize(ico3, imgMain);
                    rightRo = 0;
                }

            }

        }

        imgMain.setIcon(ico2);
        imgRoot = ico2;
        imgsave = ico;
       

        this.SliderZoom.setValue(100);
        zoom = 1;

        Original = ico2;
        xwidth = ico2.getIconWidth();
        yheight = ico2.getIconHeight();
        if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
            SliderZoom.setValue(170);
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1;
        } else {
            btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }


    }//GEN-LAST:event_btnRotateRightActionPerformed

    private void SliderZoomStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SliderZoomStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_SliderZoomStateChanged
    private static void print(final Image img) {
        PrinterJob printjob = PrinterJob.getPrinterJob();
        printjob.setJobName("Print");

        ImgPrinter printable = new ImgPrinter(img);

        try {
            System.out.println("Printing.");
            printable.printPage();
        } catch (PrinterException ex) {
            System.out.println("NO PAGE FOUND." + ex);
        }
    }
    private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
        // TODO add your handling code here:
       /* File f = lstImg.get(indexImage);
         ImageIcon imgOriginal = new ImageIcon(f.getPath());
         PrintService service = PrintServiceLookup.lookupDefaultPrintService();
         DocPrintJob job = service.createPrintJob();
         DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
         MyPrintable.printImage = imgOriginal;
         SimpleDoc doc = new SimpleDoc(new MyPrintable(), flavor, null);
         try {
         job.print(doc, null);


         } catch (PrintException ex) {
         Logger.getLogger(ViewPhotos.class
         .getName()).log(Level.SEVERE, null, ex);
         }*/
        File f = lstImg.get(indexImage);
        ImageIcon imgOriginal = new ImageIcon(f.getPath());

        Image a = (imgOriginal).getImage();
        print(a);
    }//GEN-LAST:event_btnPrintActionPerformed

    private void btnSendMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendMailActionPerformed
        // TODO add your handling code here:

        TestMail a = new TestMail(null, rootPaneCheckingEnabled);
        a.setVisible(true);

        if (a.getIsClose() == false) {
            File f = lstImg.get(indexImage);
            String file = f.getPath();
            String[] str = a.getTo();
            String e = a.getFrom();
            String p = a.getPass();
            //   if (str != null && !"".equals(str) && e != null && !"".equals(e) && p != null && !"".equals(p)) {
//JOptionPane.showMessageDialog(null,str);
            try {
                SendMail.send(e, p, str, file);
                JOptionPane.showMessageDialog(null, "Gửi Email thành công .Hình ảnh đã được gửi", "Thông báo", 1);



            } catch (Exception ex) {
                Logger.getLogger(ViewPhotos.class
                        .getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(
                        null, "gửi mail thất bại .Hãy kiểm tra lại.", "Thông báo", 1);
            }
            //   }
        }

    }//GEN-LAST:event_btnSendMailActionPerformed

    private void btnZoomInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnZoomInActionPerformed
        // TODO add your handling code here:
        zoom += 0.1;
        SliderZoom.setValue(SliderZoom.getValue() + 10);
        int x = (int) ((int) xwidth * zoom);
        int y = (int) ((int) yheight * zoom);
        if (x >= w) {
            SliderZoom.setValue(170);
            x = w;
            y = (int) ((int) yheight * (zoom - 0.1));
            this.btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
        }
        if (y >= h) {
            SliderZoom.setValue(170);
            y = h;
            x = (int) ((int) xwidth * (zoom - 0.1));
            this.btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
        }
        ImageIcon ico1 = imageHelper.resizeIcon(Original, x, y);
        imgMain.setIcon(ico1);
        imgRoot = ico1;
        this.btnZoomOut.setEnabled(true);
    }//GEN-LAST:event_btnZoomInActionPerformed

    private void btnZoomOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnZoomOutActionPerformed
        // TODO add your handling code here:
        zoom = zoom - 0.1;
        SliderZoom.setValue(SliderZoom.getValue() - 10);
        int x = (int) ((int) xwidth * zoom);
        int y = (int) ((int) yheight * zoom);
        if (x >= xwidth || y > yheight) {
            x = xwidth;
            y = yheight;
        } else {
            if (x <= xwidth * 0.3) {
                x = (int) (xwidth * 0.3);
                y = (int) ((int) yheight * (zoom + 0.1));
                this.btnZoomOut.setEnabled(false);
                jMenuItem5.setEnabled(false);
            }
            if (y <= (yheight * 0.3)) {
                y = (int) (yheight * 0.3);
                x = (int) ((int) xwidth * (zoom + 0.1));
                this.btnZoomOut.setEnabled(false);
                jMenuItem5.setEnabled(false);
            }
            this.btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }
        ImageIcon ico1 = imageHelper.resizeIcon(Original, x, y);
        imgMain.setIcon(ico1);
        imgRoot = ico1;
    }//GEN-LAST:event_btnZoomOutActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
         if (imgsave != null) {
            SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
            savearr.add(a);
            imgsave = null;
        }
        if (savearr.size() > 0) {
            int x = JOptionPane.showConfirmDialog(null, "Bạn muốn lưu các tấm hình đã thay đổi không?", "Comfirm ", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (x == 0) {
                for (int i = 0; i < savearr.size(); i++) {
                    int index = savearr.get(i).getIndex();
                    File imagefile = new File(lstImg.get(index).getPath());
                    try {
                      
                        ImageIO.write((RenderedImage) savearr.get(i).getImg(), "jpeg", imagefile);
                      
                    } catch (IOException ex) {
                        Logger.getLogger(ViewPhotos.class
                                .getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        frmparent.setVisible(true);
    }//GEN-LAST:event_formWindowClosing

    private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackActionPerformed
        // TODO add your handling code here:
        frmparent.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_btnBackActionPerformed

    private void SliderBlurMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SliderBlurMouseReleased
        // TODO add your handling code here:

        jMenuItem3.setEnabled(true);
        jMenuItem6.setEnabled(true);
         jMenuItem7.setEnabled(true);
        int value = this.SliderBlur.getValue();
      
      
        int iBlur = 2;
        if (value <= 66) {
            iBlur = 0;
        } else if (value > 66 && value <= 133) {
            iBlur = 1;
        }
        if (iBlur != indexBlur) {
            indexBlur = iBlur;
            if (indexBlur == 0) {
                BufferedImage bimg = null;
                if (imgRo == null) {
                    bimg = toBufferedImage(imgRoot.getImage());
                    
                } else {
                    bimg = toBufferedImage(imgRo);
                }
                Image img = convertToSuperGray(bimg, value);
   jMenuItem43.setEnabled(true);
    jMenuItem44.setEnabled(false);
                imgMain.setIcon(new ImageIcon(img));
            } else if (indexBlur == 1) {
                BufferedImage bimg = null;
                if (imgRo == null) {
                    bimg = toBufferedImage(imgRoot.getImage());
                } else {
                    bimg = toBufferedImage(imgRo);
                }
                //   bimg = convertToGray(bimg);
                ImageIcon bi = convertToGray(bimg);
                   jMenuItem43.setEnabled(true);
                    jMenuItem44.setEnabled(false);
                imgMain.setIcon(bi);
            } else {
                if (imgRo == null) {
                    imgMain.setIcon(imgRoot);
                } else {
                    if(imgRo2==null)
                    {
                        imgMain.setIcon(imgRoot);
                    }
                    else
                    imgMain.setIcon(new ImageIcon(imgRo2));
                }
                
            jMenuItem43.setEnabled(false);
             jMenuItem44.setEnabled(true);
            }
        } else if (iBlur == 1) {
            BufferedImage bimg = null;
            if (imgRo == null) {
                bimg = toBufferedImage(imgRoot.getImage());
            } else {
                bimg = toBufferedImage(imgRo);
            }
            Image img = convertToSuperGray(bimg, value);
            imgMain.setIcon(new ImageIcon(img));
             jMenuItem43.setEnabled(true);
              jMenuItem44.setEnabled(false);
        }

        Icon imgOriginal = imgMain.getIcon();
        imgRo = ((ImageIcon) imgOriginal).getImage();
        imgsave = imgRo;
        imgRo3=imgRo;
        
        
    }//GEN-LAST:event_SliderBlurMouseReleased

    private void SliderBrightnessMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SliderBrightnessMouseReleased
        // TODO add your handling code here:
        if(SliderBrightness.getValue() ==200)
        {
             jMenuItem45.setEnabled(false);
        }
        else
        {
             jMenuItem45.setEnabled(true);
        }
        if(SliderBrightness.getValue() ==0)
        {
           jMenuItem46.setEnabled(false);
        }
        else
        {
            jMenuItem46.setEnabled(true);
        }
        jMenuItem3.setEnabled(true);
        jMenuItem6.setEnabled(true);
         jMenuItem7.setEnabled(true);
        BufferedImage im;
        if (imgRo == null) {
            im = toBufferedImage(imgRoot.getImage());
        } else {
           if(imgRo3 != null)
           {
            im = toBufferedImage(imgRo3);
           }
           else
           {
               im = toBufferedImage(imgRoot.getImage());
           }
            // sa
        }

        float brightenFactor = (float) SliderBrightness.getValue() / 100;
        String s = brightenFactor + "f";
        brightenFactor = Float.parseFloat(s);

        RescaleOp op = new RescaleOp(brightenFactor, 0, null);
        im = op.filter(im, im);
        ImageIcon n = new ImageIcon(im);
        //  ImageIcon n = new ImageIcon(im);
        imgMain.setIcon(n);

        Icon imgOriginal = imgMain.getIcon();
        imgRo = ((ImageIcon) imgOriginal).getImage();
        imgsave = n.getImage();
        imgRo2=imgRo;


    }//GEN-LAST:event_SliderBrightnessMouseReleased

    private void SliderZoomMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SliderZoomMouseReleased
        // TODO add your handling code here:
        double i = (double) this.SliderZoom.getValue() / 100;
        zoom = i;
        if (i == 0.3) {
            btnZoomOut.setEnabled(false);
            jMenuItem5.setEnabled(false);
        } else {
            btnZoomOut.setEnabled(true);
            jMenuItem5.setEnabled(true);

        }
        //  Icon imgOriginal = imgMain.getIcon();

        int x_old = imgRoot.getIconWidth();
        int y_old = imgRoot.getIconHeight();
        int x = (int) ((int) xwidth * i);
        int y = (int) ((int) yheight * i);
        if (x >= w || y >= h) {
            /*x = w;
             y = y_old;*/
            ImageIcon ico1 = imageHelper.imageSize(Original, imgMain);
            imgMain.setIcon(ico1);
            imgRoot = ico1;
            btnZoomIn.setEnabled(false);
            jMenuItem4.setEnabled(false);
            zoom = 1.7;
        } else {
            ImageIcon ico1 = imageHelper.resizeIcon(Original, x, y);
            imgMain.setIcon(ico1);
            imgRoot = ico1;
            btnZoomIn.setEnabled(true);
            jMenuItem4.setEnabled(true);
        }
        /* if (y >= h) {
         /*  y = h;
         x = x_old;
            
         btnZoomIn.setEnabled(false);
         jMenuItem4.setEnabled(false);
         zoom = 1.7;
         } else {
         btnZoomIn.setEnabled(true);
         jMenuItem4.setEnabled(true);
         }*/


    }//GEN-LAST:event_SliderZoomMouseReleased

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        SlideShow_FullScreen ss = new SlideShow_FullScreen(new ImageIcon(lstImg.get(indexImage).getPath()), this);
        ss.LoadImage();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        int time = Integer.parseInt(lbDislayTime.getText());
        SlideShow_FullScreen ss = new SlideShow_FullScreen(lstImg, this, indexImage, time);
        ss.LoadImage();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem23ActionPerformed
        btnRotateRightActionPerformed(evt);        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem23ActionPerformed

    private void jMenuItem24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem24ActionPerformed
        btnRotateLeftActionPerformed(evt);        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem24ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
        btnZoomInActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
        btnZoomOutActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem41ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem41ActionPerformed
        // TODO add your handling code here:
        btnPrintActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem41ActionPerformed

    private void jMenuItem42ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem42ActionPerformed
        btnSendMailActionPerformed(evt);         // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem42ActionPerformed

    private void jMenuItem45ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem45ActionPerformed
        // TODO add your handling code here:
         SliderBrightness.setValue(SliderBrightness.getValue()+10);
         SliderBrightnessMouseReleased(null);
         if(SliderBrightness.getValue()>100)
         {
             jMenuItem45.setEnabled(false);
         }
    }//GEN-LAST:event_jMenuItem45ActionPerformed

    private void jMenuItem43ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem43ActionPerformed
        // TODO add your handling code here:
        SliderBlur.setValue(SliderBlur.getValue()+100);
        SliderBlurMouseReleased(null);
        if(SliderBlur.getValue()>100)
        {
            jMenuItem43.setEnabled(false);
        }
       
    }//GEN-LAST:event_jMenuItem43ActionPerformed

    private void jMenuItem36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem36ActionPerformed
        // TODO add your handling code here:
         if (imgsave != null) {
            SaveArr a = new SaveArr(indexImage, toBufferedImage(imgsave));
            savearr.add(a);
            imgsave = null;
        }
        if (savearr.size() > 0) {
            int x = JOptionPane.showConfirmDialog(null, "Bạn muốn lưu các tấm hình đã thay đổi không?", "Comfirm ", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (x == 0) {
                for (int i = 0; i < savearr.size(); i++) {
                    int index = savearr.get(i).getIndex();
                    File imagefile = new File(lstImg.get(index).getPath());
                    try {
                      
                        ImageIO.write((RenderedImage) savearr.get(i).getImg(), "jpeg", imagefile);
                      
                    } catch (IOException ex) {
                        Logger.getLogger(ViewPhotos.class
                                .getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        this.setVisible(false);
        frmparent.setVisible(true);
    }//GEN-LAST:event_jMenuItem36ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        // TODO add your handling code here:
        File file = lstImg.get(indexImage);
        if (file.exists()) {
            file.delete();

            lstImg.remove(indexImage);
            if (indexImage == lstImg.size()) {
                indexImage--;
            }
            File f = lstImg.get(indexImage);
            ImageIcon imgOriginal = new ImageIcon(f.getPath());
            ImageIcon icothumnail = imageHelper.imageSize(imgOriginal, img4);
            img4.setIcon(icothumnail);

            ImageIcon ico1;
            int indexImg = indexImage - 3;
            for (int i = 0; i < 3; i++) {
                if (indexImg < 0) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }
            indexImg = indexImage + 1;
            for (int i = 4; i < 7; i++) {
                if (indexImg >= lstImg.size()) {
                    icothumnail = new ImageIcon("");
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(null);
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 0));
                } else {
                    ico1 = new ImageIcon(lstImg.get(indexImg).getPath());
                    icothumnail = imageHelper.imageSize(ico1, arrThumnail.get(i));
                    arrThumnail.get(i).setIcon(icothumnail);
                    arrThumnail.get(i).setName(Integer.toString(indexImg));
                    arrThumnail.get(i).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
                }
                indexImg++;
            }


            ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
            imgMain.setIcon(ico);
            int tt = indexImage + 1;
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            jLabel1.setText(f.getName() + "  " + sdf.format(f.lastModified()) + "  " + ico.getIconWidth() + "x" + ico.getIconHeight() + " pixels  " + f.length() + "KB  (" + tt + " of " + lstImg.size() + ")");

            xwidth = ico.getIconWidth();
            yheight = ico.getIconHeight();
            Original = imgOriginal;
            if (xwidth == imgMain.getWidth() || yheight == imgMain.getHeight()) {
                SliderZoom.setValue(170);
                btnZoomIn.setEnabled(false);
                jMenuItem4.setEnabled(false);
                zoom = 1;
            } else {
                btnZoomIn.setEnabled(true);
                jMenuItem4.setEnabled(true);
            }

            if (indexImage == lstImg.size() - 1) {
                btnNext.setEnabled(false);
            }



        }

    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        File f = lstImg.get(indexImage);
        JFileChooser saveFile = new JFileChooser();
        saveFile.setAcceptAllFileFilterUsed(false);
        saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".jpg", "jpg"));
        saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".jpeg", "jpeg"));
        saveFile.addChoosableFileFilter(new FileNameExtensionFilter(".png", "png"));
        saveFile.setSelectedFile(f);
        saveFile.setName("Copy to");
        //saveFile.set
        int returnVal = saveFile.showSaveDialog(null);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = saveFile.getSelectedFile();
            //    File selectedFile = fileChooser.getSelectedFile();
            String fileName = null;
            String EXTENSION = null;
            try {
                fileName = file.getCanonicalPath();
                EXTENSION = saveFile.getFileFilter().getDescription();
                //   String name = EXTENSION.substring(1);
            } catch (IOException ex) {
                Logger.getLogger(ViewPhotos.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (!fileName.endsWith(EXTENSION)) {
                file = new File(fileName + EXTENSION);
            }
            if (file.exists()) {
                JOptionPane.showMessageDialog(null, "File đã tồn tại trong trong thư mục hiện tại");
            } else {
                String path = f.getAbsolutePath();
                Image image = new ImageIcon(path).getImage();
                BufferedImage bi = imageHelper.toBufferedImage(image);
                String name = EXTENSION.substring(1);

                try {
                    ImageIO.write(bi, name, file);
                } catch (IOException ex) {
                    Logger.getLogger(frmMain.class.getName()).log(Level.SEVERE, null, ex);
                }


            }

        }
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
        File f = lstImg.get(indexImage);
        JFileChooser saveFile = new JFileChooser();
        saveFile.setAcceptAllFileFilterUsed(false);

        saveFile.setSelectedFile(f);
        saveFile.setName("Copy to");
        //saveFile.set
        int returnVal = saveFile.showSaveDialog(null);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = saveFile.getSelectedFile();
            //    File selectedFile = fileChooser.getSelectedFile();
            String fileName = null;
            String EXTENSION = null;
            try {
                fileName = file.getCanonicalPath();
                String path = f.getAbsolutePath();
                int index1 = path.lastIndexOf(".");
                String eFile = "." + path.substring(index1 + 1, path.length());
                EXTENSION = eFile;
                //   String name = EXTENSION.substring(1);
            } catch (IOException ex) {
                Logger.getLogger(ViewPhotos.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (!fileName.endsWith(EXTENSION)) {
                file = new File(fileName + EXTENSION);
            }
            if (file.exists()) {
                JOptionPane.showMessageDialog(null, "File đã tồn tại trong trong thư mục hiện tại");
            } else {

                BufferedImage bi = imageHelper.toBufferedImage(imgsave);
                String name = EXTENSION.substring(1);

                try {
                    ImageIO.write(bi, name, file);
                    jMenuItem3.setEnabled(false);
                    jMenuItem6.setEnabled(false);
                     jMenuItem7.setEnabled(false);
                    imgsave = null;
                  
                } catch (IOException ex) {
                    Logger.getLogger(frmMain.class.getName()).log(Level.SEVERE, null, ex);
                }


            }

        }
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        File imagefile = new File(lstImg.get(indexImage).getPath());
        try {
            
            BufferedImage i = toBufferedImage(imgsave);
            ImageIO.write((RenderedImage) i, "jpeg", imagefile);
            jMenuItem3.setEnabled(false);
            jMenuItem6.setEnabled(false);
            jMenuItem7.setEnabled(false);
            imgsave = null;
             ImageIcon imgOriginal = new ImageIcon(lstImg.get(indexImage).getPath());

        ImageIcon ico = imageHelper.imageSize(imgOriginal, imgMain);
        LoadThumn(ico, imgOriginal);
           

        } catch (IOException ex) {
            Logger.getLogger(ViewPhotos.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem46ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem46ActionPerformed
        // TODO add your handling code here:
        SliderBrightness.setValue(SliderBrightness.getValue()-10);
         SliderBrightnessMouseReleased(null);
         if(SliderBrightness.getValue()==0)
         {
             jMenuItem46.setEnabled(false);
         }
    }//GEN-LAST:event_jMenuItem46ActionPerformed

    private void jMenuItem44ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem44ActionPerformed
        // TODO add your handling code here:
        SliderBlur.setValue(SliderBlur.getValue()-100);
        SliderBlurMouseReleased(null);
        if(SliderBlur.getValue()==0)
        {
            jMenuItem44.setEnabled(false);
        }
    }//GEN-LAST:event_jMenuItem44ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        imgMain.setIcon(imgUndo);
       imgsave=null;
       imgRo=null;
       imgRo2=null;
       imgRo3=null;
       left =0;
       right=0;
       imgRo1=null;
       jMenuItem7.setEnabled(false);
       SliderBlur.setValue(200);
       SliderBrightness.setValue(100);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem30ActionPerformed
        // TODO add your handling code here:
       frmAboutUS a = new frmAboutUS(null, rootPaneCheckingEnabled);
        a.setVisible(true);
        
        
    }//GEN-LAST:event_jMenuItem30ActionPerformed

    public Image convertToSuperGray(BufferedImage img, int value) {
        ImageFilter filter = new GrayFilter(true, value);
        ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
        return this.createImage(producer);
    }

    public ImageIcon convertToGray(BufferedImage img) {
        /* ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
         ColorConvertOp op = new ColorConvertOp(cs, null);
         return op.filter(img, null);*/

        int w1 = img.getWidth();
        int h1 = img.getHeight();
        // int value[][] = new int[w1][h1];
        BufferedImage gray = new BufferedImage(w1, h1, 1);// new image
        int value, alpha, r, g, b;
        for (int i = 0; i < w1; i++) {
            for (int j = 0; j < h1; j++) {
                value = img.getRGB(i, j); // read and store pixel value
                alpha = (value >> 24) & 0xFF;
                r = (value >> 16) & 0xFF;
                g = (value >> 8) & 0xFF;
                b = (value) & 0xFF;

                value = (r + g + b) / 3; // grey by averaging the pixels
                r = g = b = value;
                value = (alpha << 24) + (r << 16) + (g << 8) + b;
                gray.setRGB(i, j, value);
            }
        }
        ImageIcon n = new ImageIcon(gray);

        return n;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ViewPhotos.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ViewPhotos.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ViewPhotos.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ViewPhotos.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ViewPhotos frame = new ViewPhotos(new javax.swing.JFrame(), true, lstImg, indexImage);
                frame.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                frame.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSlider SliderBlur;
    private javax.swing.JSlider SliderBrightness;
    private javax.swing.JSlider SliderZoom;
    private javax.swing.JButton btnBack;
    private org.jdesktop.swingx.JXButton btnCong;
    private javax.swing.JButton btnFullScreen;
    private javax.swing.JButton btnNext;
    private javax.swing.JButton btnPrevious;
    private org.jdesktop.swingx.JXButton btnPrint;
    private javax.swing.JButton btnRotateLeft;
    private javax.swing.JButton btnRotateRight;
    private org.jdesktop.swingx.JXButton btnSendMail;
    private javax.swing.JButton btnSlideShow;
    private org.jdesktop.swingx.JXButton btnTru;
    private org.jdesktop.swingx.JXButton btnZoomIn;
    private org.jdesktop.swingx.JXButton btnZoomOut;
    private javax.swing.JLabel img1;
    private javax.swing.JLabel img2;
    private javax.swing.JLabel img3;
    private javax.swing.JLabel img4;
    private javax.swing.JLabel img5;
    private javax.swing.JLabel img6;
    private javax.swing.JLabel img7;
    private javax.swing.JLabel imgMain;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu10;
    private javax.swing.JMenu jMenu11;
    private javax.swing.JMenu jMenu12;
    private javax.swing.JMenu jMenu14;
    private javax.swing.JMenu jMenu15;
    private javax.swing.JMenu jMenu16;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem23;
    private javax.swing.JMenuItem jMenuItem24;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem30;
    private javax.swing.JMenuItem jMenuItem36;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem41;
    private javax.swing.JMenuItem jMenuItem42;
    private javax.swing.JMenuItem jMenuItem43;
    private javax.swing.JMenuItem jMenuItem44;
    private javax.swing.JMenuItem jMenuItem45;
    private javax.swing.JMenuItem jMenuItem46;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPopupMenu.Separator jSeparator17;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JPopupMenu.Separator jSeparator9;
    private org.jdesktop.swingx.JXButton jXButton4;
    private org.jdesktop.swingx.JXLabel jXLabel2;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXPanel jXPanel2;
    private org.jdesktop.swingx.JXPanel jXPanel3;
    private org.jdesktop.swingx.JXPanel jXPanel4;
    private javax.swing.JLabel lbDislayTime;
    // End of variables declaration//GEN-END:variables
}
